package com.cg.service.impl;

import com.cg.dao.HealthInfoMapper;
import com.cg.dto.HealthInfoPageDto;
import com.cg.service.HealthInfoService;
import com.cg.vo.HealthInfoVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HealthInfo)表服务实现类
 *
 * @author chengong
 * @since 2024-01-14 15:38:18
 */
@Service("healthInfoService")
public class HealthInfoServiceImpl implements HealthInfoService {
    @Resource
    private HealthInfoMapper healthInfoMapper;


    /**
     * 健康资讯信息展示
     */
    @Override
    public List<HealthInfoVo> queryHealthList() {
        return healthInfoMapper.queryHealthList();
    }


    /**
     * 根据标题模糊查询资讯
     */
    @Override
    public PageInfo<HealthInfoVo> queryHealthListByTitle(HealthInfoPageDto healthInfoPageDto) {
        PageHelper.startPage(healthInfoPageDto.getPageNum(),healthInfoPageDto.getPageSize());
        List<HealthInfoVo> healthInfoVos = healthInfoMapper.queryHealthListByTitle(healthInfoPageDto.getInfoTitle());
        PageInfo<HealthInfoVo> pageInfo = new PageInfo<>(healthInfoVos);
        return pageInfo;
    }
}
